package com.lanou.beautifulwardrobe.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lanou.beautifulwardrobe.Brand.Adapter.BrandRankAdapter;
import com.lanou.beautifulwardrobe.R;
import com.lanou.beautifulwardrobe.entify.RiseItem;

import java.util.List;

/**
 * Created by dllo on 15/10/30.
 */
public class BrandRankActivity extends Activity implements View.OnClickListener {
    private RecyclerView rankRecyclerView;
    private BrandRankAdapter adapter;
    private GridLayoutManager manager;
    private TextView rankingTitle;
    private ImageButton rankingBack;
   // private LinearLayout rankLinearLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.brandranking);
        initView();
        initData();
    }

    private void initView() {
        rankRecyclerView = (RecyclerView) findViewById(R.id.rankRecyclerView);
        rankingTitle = (TextView) findViewById(R.id.rankingTitle);
        rankingBack = (ImageButton) findViewById(R.id.rankingBack);
      //  rankLinearLayout= (LinearLayout) findViewById(R.id.rankLinearLayout);
        manager = new GridLayoutManager(this, 1);
        adapter = new BrandRankAdapter(this);
        initListener();
    }

    private void initListener() {
        rankingBack.setOnClickListener(this);
    }

    private void initData() {
        rankRecyclerView.setLayoutManager(manager);
        List<RiseItem> items = (List<RiseItem>) getIntent().getSerializableExtra("arr");
        String title = getIntent().getStringExtra("title");
        rankingTitle.setText(title);
        adapter.addData(items);
        rankRecyclerView.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        finish();
    }
}
